package view.UIPlayer{
	
	import event.CustomEvent;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class ButtonViewLayer extends Sprite{
		
		[Embed(source="assets/images/cxks.png")]
		private var cxks:Class;
		[Embed(source="assets/images/jia.png")]
		private var jia:Class;		
		[Embed(source="assets/images/jian.png")]
		private var jian:Class;
		[Embed(source="assets/images/kanpai.png")]
		private var kanpai:Class;
		[Embed(source="assets/images/ksfp.png")]
		private var ksfp:Class;
		[Embed(source="assets/images/unjia.png")]
		private var unjia:Class;
		[Embed(source="assets/images/unjian.png")]
		private var unjian:Class;
		[Embed(source="assets/images/unkanpai.png")]
		private var unkanpai:Class;
		[Embed(source="assets/images/zlyz.png")]
		private var zlyz:Class;
		
		private var startBtn:Sprite;
		private var againBtn:Sprite;
		private var restartBtn:Sprite;
		private var showBtn:Sprite;
		private var unshowBtn:Sprite;
		private var unaddChip:Sprite;
		private var unsubChip:Sprite;
		private var addChip:Sprite;
		private var subChip:Sprite;
		
		public function ButtonViewLayer(){
			init();
		}
		
		private function init():void{
			startBtn = new Sprite();
			addChild(startBtn);
			startBtn.addChild(new ksfp());
			startBtn.x = 635;
			startBtn.y = 535;			
			startBtn.buttonMode = true;
			startBtn.addEventListener(MouseEvent.CLICK,onClickStartBtn);
			
			againBtn = new Sprite();
			addChild(againBtn);
			againBtn.addChild(new zlyz());
			againBtn.x = 635;
			againBtn.y = 535;
			againBtn.visible = false;
			againBtn.buttonMode = true;
			againBtn.addEventListener(MouseEvent.CLICK,onClikAgainBtn);
			
			restartBtn = new Sprite();
			restartBtn.addChild( new cxks() );
			addChild(restartBtn);
			restartBtn.x = 635;
			restartBtn.y = 535;
			restartBtn.visible = false;
			restartBtn.buttonMode = true;
			restartBtn.addEventListener(MouseEvent.CLICK,onClikReStartBtn);
			
			showBtn = new Sprite();
			showBtn.addChild(new kanpai() );
			addChild(showBtn);
			showBtn.x = 565;
			showBtn.y = 555;
			showBtn.buttonMode = false;
			showBtn.addEventListener(MouseEvent.CLICK,onClickShowBtn);
			
			unshowBtn = new Sprite();
			unshowBtn.addChild(new unkanpai() );
			addChild(unshowBtn);
			unshowBtn.x = 565;
			unshowBtn.y = 555;
			unshowBtn.visible = true;
			
			unaddChip = new Sprite();
			unaddChip.addChild(new unjia());
			addChild(unaddChip);
			unaddChip.x = 520;
			unaddChip.y = 555;		
			
			unsubChip = new Sprite();
			unsubChip.addChild(new unjian());
			addChild(unsubChip);
			unsubChip.x = 480;
			unsubChip.y = 555;
			
			
			addChip = new Sprite();
			addChip.addChild(new jia());
			addChild(addChip);
			addChip.x = 520;
			addChip.y = 555;
			addChip.buttonMode = true;
//			addChip.addEventListener(MouseEvent.CLICK,onClikAddChipBtn);
			
			subChip = new Sprite();
			subChip.addChild( new jian());
			addChild(subChip);
			subChip.x = 480;
			subChip.y = 555;		
			subChip.buttonMode = true;
//			subChip.addEventListener(MouseEvent.CLICK,onClikSubChipBtn);
			
		}
		
		public function updateGameStart2():void{
			startBtn.visible = false;
			againBtn.visible = true;
			restartBtn.visible = false;	
			showBtn.visible = true;
			showBtn.buttonMode = true;
			unshowBtn.visible = false;
		}
		
		private function onClickStartBtn(e:Event):void{
			var evStart:CustomEvent = new CustomEvent(CustomEvent.ONCLIK_START, true);
			evStart.BTNState = 1;
			dispatchEvent(evStart);
		}
		
		private function onClikAgainBtn(e:Event):void{
			var evStart:CustomEvent = new CustomEvent(CustomEvent.ONCLIK_START, true);
			evStart.BTNState = 2;
			dispatchEvent(evStart);
		}
		
		private function onClikReStartBtn(e:Event):void{
			var evStart:CustomEvent = new CustomEvent(CustomEvent.ONCLIK_START, true);
			evStart.BTNState = 3;
			dispatchEvent(evStart);
		}
		
		private function onClickShowBtn(e:Event):void{
			dispatchEvent(new CustomEvent(CustomEvent.ONCLIK_SHOW,true));
		}
		
		
	}
}